package org.example.blog.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.blog.entity.Blog;

import java.util.List;

@Mapper
public interface BlogMapper {
    //查找数据库里的所有博客数据
    @Select("select * from blog")
    List<Blog> findAll();
    //查询分页数据,跳过前offset行，返回接下来的limit行数据
    @Select("select * from blog order by created_at desc limit #{limit} offset #{offset}")
    List<Blog> findBlogsByPage(int offset, int limit);
    //查询博客总数量
    @Select("select count(*) from blog")
    int countBlogs();
}
